#include"com.h"
int main()
{
  umask(0);
  if(mkfifo(File_Name, 0666)<0)
  {//创建失败
    perror("mkfifo failed!!!\n");
    return 1;
  }
  int fd = open(File_Name, O_RDONLY);//以读的方式打开
  if(fd<0)
  {
    perror("open failed!!!\n");
    return 2;
  }
  char msg[128];
  while(1)
  {
    msg[0] = '\0';
    ssize_t s = read(fd, msg, sizeof(msg)-1);
    if(s>0)
    {
      msg[s]='\0';
      printf("client# %s\n",msg);
    }
    else if(s==0)
    {
      printf("client quit!\n");
      break;
    }
    else 
    {
      printf("read error!!!\n");
      break;
    }
  }
  close(fd);
  return 0;
}
